// @ts-nocheck
// 动态表单字段类型映射表
// 每种表单字段类型对应一个独立的渲染组件

// 导入各种表单项组件
import InputField from './components/fields/InputField.vue'
import SelectField from './components/fields/SelectField.vue'
import AutoCompleteField from './components/fields/AutoCompleteField.vue'
import DatePickerField from './components/fields/DatePickerField.vue'
import RadioField from './components/fields/RadioField.vue'
import CheckboxField from './components/fields/CheckboxField.vue'
import NumberField from './components/fields/NumberField.vue'
import TextareaField from './components/fields/TextareaField.vue'
import SwitchField from './components/fields/SwitchField.vue'
import UploadField from './components/fields/UploadField.vue'
import CustomField from './components/fields/CustomField.vue'

// 字段类型到组件的映射表
export const fieldMap = {
  // 基础输入类型
  input: InputField,
  text: InputField,
  textarea: TextareaField,
  number: NumberField,
  password: InputField,
  
  // 选择类型
  select: SelectField,
  radio: RadioField,
  checkbox: CheckboxField,
  switch: SwitchField,
  
  // 自动完成
  autoComplete: AutoCompleteField,
  
  // 日期时间
  date: DatePickerField,
  datePicker: DatePickerField,
  time: DatePickerField,
  datetime: DatePickerField,
  
  // 文件上传
  upload: UploadField,
  file: UploadField,
  
  // 自定义类型
  custom: CustomField,
}

// 注册自定义字段类型
export function registerFieldType(type: string, component: any) {
  fieldMap[type] = component
}

// 获取字段组件
export function getFieldComponent(type: string) {
  return fieldMap[type] || fieldMap['input']
}

// 获取所有已注册的字段类型
export function getRegisteredFieldTypes() {
  return Object.keys(fieldMap)
}

// 检查字段类型是否已注册
export function isFieldTypeRegistered(type: string) {
  return type in fieldMap
} 